Skip to content

fix: server network access and YouTube Shorts support - #233

Merged
thcp merged 7 commits into
mainfrom
fix/server-network-and-shorts-support
Jun 28, 2026
Merged

fix: server network access and YouTube Shorts support#233
thcp merged 7 commits into
mainfrom
fix/server-network-and-shorts-support

Conversation

@thcp

@thcp thcp commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Server/Docker network fix (discussion Tool for musicians #216): two layers were blocking network clients from reaching headless deployments. docker-compose.yml was binding to 127.0.0.1 (Docker host level) and _default_allow_network() was returning False unconditionally (application level). Now allow_network defaults to True when STEMDECK_DESKTOP is not set, and the Docker port binding is 0.0.0.0. STEMDECK_ALLOW_NETWORK still overrides either way.
  • YouTube Shorts: normalize_youtube_url() now maps youtube.com/shorts/<videoId> to the standard watch?v= form before handing the URL to yt-dlp.

Test plan

  • Docker: docker compose -f build/docker-compose.yml up --build, access from another device on the LAN - should load without "not available on the network".
  • STEMDECK_DESKTOP=1 mode: get_allow_network() returns False (desktop keeps network off by default).
  • STEMDECK_ALLOW_NETWORK=0 with no STEMDECK_DESKTOP: explicit override still locks network off.
  • Paste a YouTube Shorts URL (https://www.youtube.com/shorts/<id>) - should process successfully.
  • uv run pytest tests/test_url_validation.py -v - all 18 tests pass.

thcp added 7 commits June 28, 2026 19:27
Normalize youtube.com/shorts/<videoId> to the standard watch?v= form
so yt-dlp receives a URL its extractor already handles.

Adds two test cases covering www. and m. variants.
Two layers were blocking headless server deployments from accepting
network clients (reported in discussion #216):

1. docker-compose.yml bound to 127.0.0.1:8000 - Docker itself rejected
   connections from the network before they reached the app.

2. _default_allow_network() returned False unconditionally, so the
   network_gate middleware blocked all non-loopback requests even when
   Docker networking was configured correctly.

Fix both: bind the Docker port to 0.0.0.0 and derive the network
default from STEMDECK_DESKTOP - desktop keeps its secure off-by-default
behavior; server/Docker deployments open the gate automatically since
network access is the entire point of a headless deployment.
STEMDECK_ALLOW_NETWORK still takes precedence when set explicitly.
Rename test_default_is_off to clarify it covers desktop mode (now
requires STEMDECK_DESKTOP=1). Add test_default_is_on_in_server_mode
covering the new behavior where allow_network defaults to True when
STEMDECK_DESKTOP is absent.
Network toggle and port field are desktop-only controls. In server mode
(no window.__TAURI__) the port is fixed by Docker and network access is
on by default, so exposing these controls is misleading. Hide both from
the Advanced settings tab when not running inside Tauri.
In server mode (no Tauri) the network toggle is always on and the port
is fixed by Docker, so both controls are shown but disabled so the user
can see the current state without being able to change them.
Show a explanatory note at the top of the Advanced tab when running in
server mode so users know the network and port controls are intentionally
locked and where to make changes.
@thcp
thcp marked this pull request as ready for review June 28, 2026 19:59
@thcp
thcp merged commit 2cb7214 into main Jun 28, 2026
8 checks passed
@thcp
thcp deleted the fix/server-network-and-shorts-support branch June 28, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant